package com.tangtang.core.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * Created by Administrator on 2014/4/10.
 */
public class MustLessThanValidator implements ConstraintValidator<MustLessThan, Integer> {

    MustLessThan must;

    @Override
    public void initialize(MustLessThan constraintAnnotation) {
        this.must = constraintAnnotation;
    }

    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if (value == null) {
            return false;
        }
        if (value >= must.value()) {
            return false;
        }
        return true;
    }
}
